import axios from 'axios';

export default {
  post: (url, data, error) =>
    axios({
      method: 'post',
      url: url,
      data: data,
      headers: {
        'Content-Type': 'application/json',
        Authorization: localStorage.getItem('token')
      }
    })
      .then(response => response.data)
      .catch(err => {
        if (error) {
          error(err);
        }
      }),
  get: (url, data, error) =>
    axios({
      method: 'get',
      url: url,
      params: data,
      headers: {
        'Content-Type': 'application/json',
        Authorization: localStorage.getItem('token')
      }
    })
      .then(response => response.data)
      .catch(err => {
        if (error) {
          error(err);
        }
      })
};
